package com.kayt.cyberBar.log.business.dao.impl;

import java.sql.SQLException;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;

import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

import com.kayt.cyberBar.common.PageData;
import com.kayt.cyberBar.common.dao.EntityDao;
import com.kayt.cyberBar.log.business.dao.ILogOperationDao;

@Repository("iLogOperationDao")
public class LogOperationDaoImpl<T> implements ILogOperationDao {
	
	@Autowired
	private EntityDao entityDao;

	@Override
	public <T> Long addLog(T log) throws SQLException {
		if (log != null) {
			return this.entityDao.save(log);
		}
		return 0L;
	}
	
	@Override
	public <T> void updateLog(T log) {
		this.entityDao.update(log);
	}
	
	@Override
	public <T> int deleteLog (T log) {
		if (log != null) {
			this.entityDao.deleteDetached(log);
			return 0;
		}
		return -1;
	}
	
	@Override
	public <T> int batchDelete (List<T> list) {
		if (list != null && list.size() > 0) {
			this.entityDao.batchDelete(list);
			return 0;
		}
		return -1;
	}
	
	@Override
	public List getLogListByHql(int pageNum, int pageSize, String hql, Object[] params) throws SQLException {
		return this.entityDao.getPagingDataByHql(pageNum, pageSize, hql, params);
	}
}
